class Student:
    def __init__(self, id, sname, xb, age, jg, bj, score):
        self.id = id
        self.sname = sname
        self.xb = xb
        self.age = age
        self.jg = jg
        self.bj = bj
        self.score = score


class StudentGuanliXitong:
    def __init__(self):
        self.students = []

    def add_student(self, student):
        self.students.append(student)

    def display_all_students(self):
        for student in self.students:
            self.display_student(student)
            print()

    def search_by_id(self, id):
        for student in self.students:
            if student.id == id:
                self.display_student(student)

    def search_by_name(self, name):
        for student in self.students:
            if student.sname == name:
                self.display_student(student)

    def search_by_gender(self, gender):
        for student in self.students:
            if student.xb == gender:
                self.display_student(student)

    def search_by_native_place(self, native_place):
        for student in self.students:
            if student.jg == native_place:
                self.display_student(student)

    def search_by_class(self, class_name):
        for student in self.students:
            if student.bj == class_name:
                self.display_student(student)

    def calculate_average_score_by_class(self, class_name):
        total_score = 0
        count = 0
        for student in self.students:
            if student.bj == class_name:
                total_score += student.score
                count += 1
        if count > 0:
            average_score = total_score / count
            return average_score
        else:
            return 0

    def calculate_average_score_by_gender(self, gender):
        total_score = 0
        count = 0
        for student in self.students:
            if student.xb == gender:
                total_score += student.score
                count += 1
        if count > 0:
            average_score = total_score / count
            return average_score
        else:
            return 0

    def sort_students_by_score(self):
        sorted_students = sorted(self.students, key=lambda student: student.score, reverse=True)
        for student in sorted_students:
            self.display_student(student)

    def display_student(self, student):
        print("学号:", student.id)
        print("姓名:", student.sname)
        print("性别:", student.xb)
        print("年龄:", student.age)
        print("籍贯:", student.jg)
        print("班级:", student.bj)
        print("成绩:", student.score)
        print()

    def edit_student(self, id):
        for student in self.students:
            if student.id == id:
                print("请输入修改后的学生信息：")
                student.sname = input("姓名：")
                student.xb = input("性别：")
                student.age = input("年龄：")
                student.jg = input("籍贯：")
                student.bj = input("班级：")
                student.score = input("成绩：")
                print("修改成功！")

    def delete_student(self, id):
        for student in self.students:
            if student.id == id:
                self.students.remove(student)
                print("删除成功！")
                break


def display_menu():
    print("===== 学生信息管理系统 =====")
    print("1. 录入学生信息")
    print("2. 显示所有学生信息")
    print("3. 按学号查询学生信息")
    print("4. 按姓名查询学生信息")
    print("5. 按性别查询学生信息")
    print("6. 按籍贯查询学生信息")
    print("7. 按班级查询学生信息")
    print("8. 统计班级平均成绩")
    print("9. 统计性别平均成绩")
    print("10. 按成绩排序")
    print("11. 查询某班成绩前10名的学生")
    print("12. 修改学生信息")
    print("13. 删除学生信息")
    print("0. 退出系统")
    print("=========================")
    option = input("请输入要执行的操作编号：")
    return option


def main():
    sms = StudentGuanliXitong()
    while True:
        option = display_menu()
        if option == "1":
            id = input("学号：")
            sname = input("姓名：")
            xb = input("性别：")